package cn.krund.lyc.hotlerobot.activity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import java.util.List;

import cn.krund.lyc.hotlerobot.R;

/**
 * @包名: cn.krund.lyc.hotlerobot.activity.adapter
 * @作者: 刘育成
 * @时间: 2018/3/21  17:59
 * @org: 克路德人工智能
 * @描述: TODO
 * @fileName: SearchSelectAdapter
 */

public class SearchSelectAdapter extends BaseAdapter {
    private List<String> Datas;
    private Context context;
    private LayoutInflater inflater;

    public SearchSelectAdapter(Context ctx, List<String> datas){
        this.context = ctx;
        this.Datas = datas;
        this.inflater = LayoutInflater.from(ctx);
    }
    @Override
    public int getCount() {
        return Datas.size();
    }

    @Override
    public String getItem(int i) {
        return Datas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (view == null ) {
            view = inflater.inflate(R.layout.list_cell_select_single, null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.info.setText(Datas.get(i));
        return view;
    }


    static class ViewHolder {
        TextView info;
        public ViewHolder(View view) {
            info = (TextView) view.findViewById(R.id.tv_select_info);
        }
    }

}
